\section{Theory}
\label{sec:theory}
By representing the connections between nodes as described in section
\ref{sec:implementation}, it is possible to check whether a connection exists in
$O(\log n)$. Iterating over neighbour nodes (of a specific type or over all
nodes) is in $O(n)$.

Where real-time games make use of a game-loop, this program uses event
listeners (\texttt{KeyEvent} and \texttt{MouseEvent} from the \texttt{java.awt}
library).  Since these listeners are actually threads, they make use of traps
instead of polling. This is useful, because is very CPU intensive.

The event listeners in the GUI call the \texttt{move} method in the
ScotlandYard game object, which handles the actions, checks whether the move
can be made, and whether the game is over. When all detectives have moved, the
AI is invoked by calling \texttt{move} on the \texttt{MrX} instance.
